#!/bin/sh

# Post Install Script

# set permissions

THEUID=`ps -acxouid,command | grep Finder | sed -e 's/[ ]*\([^ ]*\).*/\1/g'`

WSPID=`ps acx | grep WSWebServer | sed -n 's/[ ]*\([0-9]*\).*/\1/pg'`

if ( test -n "$WSPID" ) then
	kill -9 $WSPID
fi

sleep 2

if [ ! -f /private/tmp/ls8install ]; then
	if [ "$COMMAND_LINE_INSTALL" = 1 ] || [ -f /private/tmp/lp8windowopen ]; then
		echo "Command line install, not opening window."
	else
		for IP in `ifconfig -u -a inet 2> /dev/null | sed -n 's/.*inet \([0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\)/\1/pg' | awk '{ print $1 }'`; do

			if [[ `curl -I http://$IP/ServerAdmin.LassoApp --silent` = *Server:\ Lasso*8* ]];
			then
				echo "Opening default browser for user #${THEUID}"
				sudo -u "#${THEUID}" open "http://${IP}/ServerAdmin.LassoApp" > /dev/null 2>&1
				touch /private/tmp/lp8windowopen
				break;
			fi

		done

	fi
fi

echo ""
